<?php

/**
 * Created by PhpStorm.
 * Author: ls
 * Time: 2023/9/18 11:18
 * Desc: 会员钱包
 */
class Request_Api_V2_Member_Bag extends Request_Api_V2_Base
{
    public function __construct($request_param)
    {
        parent::__construct($request_param);
    }

    public function wallet_index()
    {
        $this->validation->rule('mid', ['Rule_Member', 'need_member']);

        return $this;
    }

    public function withdraw_audit()
    {
        $this->rules = [
            ['bank_card_number', ['not_empty']],
            ['bank_account_name', ['not_empty']],
            ['withdraw_amount', ['not_empty', 'money']],
            ['way', ['not_empty', $this->rule_in_array(Model_Api_V2_Member_Bag::WITHDRAW_WAY)]],
        ];

        if ($this->request_param['way'] == 'bank') {
            $this->rules[] = ['bank_name', ['not_empty']];
        }

        $this->validation->rule('mid', ['Rule_Member', 'need_member']);

        return $this;
    }

    public function withdraw_record()
    {
        $status = [
            Model_Api_V2_Member_Bag::STATUS_AUDIT,
            Model_Api_V2_Member_Bag::STATUS_SUCCESS,
            Model_Api_V2_Member_Bag::STATUS_REFUSED,
        ];

        $this->rules = [
            ['pagesize', ['not_empty', 'digit', $this->rule_min(1)]],
            ['page', ['not_empty', 'digit', $this->rule_min(1)]],
            ['status', ['digit', $this->rule_in_array($status)]],
            ['way', [$this->rule_in_array(Model_Api_V2_Member_Bag::WITHDRAW_WAY)]],
        ];

        $this->validation->rule('mid', ['Rule_Member', 'need_member']);

        return $this;
    }

    public function record_info()
    {
        $this->rules = [
            ['id', ['not_empty', 'digit', $this->rule_min(1)]],
        ];

        $this->validation->rule('mid', ['Rule_Member', 'need_member']);

        return $this;
    }

    public function cash_log()
    {
        $this->rules = [
            ['pagesize', ['not_empty', 'digit', $this->rule_min(1)]],
            ['page', ['not_empty', 'digit', $this->rule_min(1)]],
            ['type', ['digit']],
        ];

        $this->validation->rule('mid',  ['Rule_Member', 'need_member']);

        return $this;
    }

}